import React, { useEffect, useState } from 'react'
import { useNavigate } from 'react-router-dom'
function useSW() {
    const [login,setLogin]=useState(false)
   const nav= useNavigate()
   let token=localStorage.getItem('token')
    useEffect(()=>{
        if(token){
            setLogin(true)
        }else{
            setLogin(false)
            nav('/login')
        }
    },[])
  return {login:login}
}

export default useSW
